dojo.declare("DAdminRegisterPg", wm.Page, {
    start: function() {
        this.lookup1.setShowing(false);
        this.lookup2.setShowing(false);
    },
    "preferredDevice": "desktop",

    checkboxVendorChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {
        this.lookup1.setShowing(!inDataValue);
        this.lookup2.setShowing(!inDataValue);
        this.textAreaAddress.setShowing(inDataValue);
        this.lookup1.setDataValue("");
        this.lookup2.setDataValue("");

    },
    buttonRegistrationClick: function(inSender) {
        var isReady = true;

        if (this.textActivationCode.getDataValue() == undefined || this.textActivationCode.getDataValue() == "") isReady = false;


        if (this.emailEditor1.getDataValue() == undefined || this.emailEditor1.getDataValue() == "") isReady = false;;

        if (this.passwordEditor1.getDataValue() == undefined || this.passwordEditor1.getDataValue() == "") isReady = false;;

        if (this.nameEditor1.getDataValue() == undefined || this.nameEditor1.getDataValue() == "") isReady = false;;

        if (this.primaryPhoneEditor1.getDataValue() == undefined || this.primaryPhoneEditor1.getDataValue() == "") isReady = false;;
        if (!this.checkboxVendor.getChecked()) {
            if (this.lookup1.dataValue == undefined || this.lookup1.dataValue == "") isReady = false;;

            if (this.lookup2.dataValue == undefined || this.lookup2.dataValue == "") isReady = false;;
        } else {
            this.lookup1.setDataValue("");
            this.lookup2.setDataValue("");


        }

           
    
      
        if (isReady) {
            this.svRegisterUser.update();
        } else {
            app.toastWarning("Please fill mandatory fields", 2000);

        }
    },
    lvBlocksSuccess: function(inSender, inDeprecated) {
       
        var item = this.lookup1.dataSet.getItem(0);
        this.lookup1.setDataValue(item);
    },
    lvDoorSuccess: function(inSender, inDeprecated) {
        var item = this.lookup2.dataSet.getItem(0);
        this.lookup2.setDataValue(item);
    },
    svRegisterUserSuccess1: function(inSender, inDeprecated) {
        
        var checked = this.checkboxVendor.getChecked();
        this.formPanel1.clearData();
        this.lookup1.setDataValue("");
        this.lookup2.setDataValue("");
        this.checkboxVendor.setChecked(checked);
    },
    textActivationCodeChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {
	
	},
	svRegisterUserError1: function(inSender, inError) {
		
         this.notificationCall2.input.setValue("text", inError);
        this.notificationCall2.update();
	},
	_end: 0
});